package org.yes.util.helper;

import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

/**
 * User: mtymes
 * Date: May 27, 2010
 * Time: 1:59:14 AM
 */
public class HeaderInfo {

    // todo: maybe define custom int list to increase the performance (instead of using Integer list)
    private List<Integer> headerIndexes = new ArrayList<Integer>();

    private List<Field> fieldsToSet = new ArrayList<Field>();
    private List<Method> methodsToCallOnRowColumn = new ArrayList<Method>();
    private List<Method> methodsToCallOnHeaderColumn = new ArrayList<Method>();

    private boolean required = false;


    public void addHeaderIndex(int headerIndex) {
        headerIndexes.add(headerIndex);
    }


    public Iterator<Integer> getHeaderIndexesIterator() {
        return headerIndexes.iterator();
    }


    public boolean hasHeaderIndexesSet() {
        return headerIndexes.size() > 0;
    }


    public void clearHeaderIndexes() {
        headerIndexes.clear();
    }


    public void addFieldToSet(Field field) {
        fieldsToSet.add(field);
    }


    public Iterator<Field> getFieldToSetIterator() {
        return fieldsToSet.iterator();
    }


    public void addMethodToCallOnRowColumn(Method method) {
        methodsToCallOnRowColumn.add(method);
    }


    public Iterator<Method> getMethodToCallOnRowColumn() {
        return methodsToCallOnRowColumn.iterator();
    }


    public void addMethodToCallOnHeaderColumn(Method method) {
        methodsToCallOnHeaderColumn.add(method);
    }


    public Iterator<Method> getMethodToCallOnHeaderColumn() {
        return methodsToCallOnHeaderColumn.iterator();
    }


    public boolean isRequired() {
        return required;
    }


    public void setRequired(boolean required) {
        this.required = this.required || required;
    }
}
